<table id="sso_config_${action_id}_datagrid" ></table>
<script type="text/javascript">

$(function(){

	$('#sso_config_${action_id}_datagrid').datagrid({
		iconCls:'icon-save',
		width:'auto',
		height:'auto',
		nowrap: true,
		fit:true,
		fitColumns:true,
		striped: true,
		url:'${request.contextPath}${namespace?default('')}/mp/sso/config-datagrid.json',
		sortName: 'key',
		sortOrder: 'asc',
		remoteSort: true,
		singleSelect : true,
		idField:'id',
		onBeforeLoad:function(){$('#sso_config_${action_id}_datagrid').datagrid('unselectAll');},
		columns:[[
					{field:'id',title:'${action.getDatagridTitle('id')}',width:80,align:'center'},
					{field:'name',title:'${action.getDatagridTitle('name')}',width:80,align:'center'},
					{field:'key',title:'${action.getDatagridTitle('key')}',width:80,align:'center'},
					{field:'value',title:'${action.getDatagridTitle('value')}',width:80,align:'center'},
					{field:'usable',title:'${action.getDatagridTitle('usable')}',width:80,align:'center'},
					{field:'group',title:'${action.getDatagridTitle('group')}',width:80,align:'center'},
					{field:'caozuo',title:'${action.getProperty('net.esj.background.message','bg.datagrid.action')}',width:120,align:'center',formatter:function(val, rec){
						return '<a href="javascript:;;" onclick="sso_config_${action_id}_edit(\''+rec.id+'\')" >${action.getProperty('net.esj.background.message','bg.datagrid.modify')}</a>';
					}}
				]],
		pagination:false,
		rownumbers:true,
		toolbar:[{
			id:'btnadd',
			text:'${action.getProperty('net.esj.background.message','bg.datagrid.add')}',
			iconCls:'icon-add',
			handler:function(){
				$('<div/>').dialog({
					href:'${request.contextPath}${namespace?default('')}/mp/sso/config-form.htm?action_id=${action_id}',
					width:500,   
					height:500,   
					title: '添加',
					modal:true,
					maximizable:false,
					collapsible:false,
					minimizable:false,
					resizable:false,
					buttons:[{iconCls : 'icon-ok',
								text:'${action.getProperty('net.esj.background.message','bg.datagrid.save')}',
								handler:function(){
									var d = $(this).closest('.window-body');
									$('#sso_config_${action_id}_form').form('submit', {
										url : '${request.contextPath}${namespace?default('')}/mp/sso/config-add.json',
										onSubmit: function(){
											return $(this).form('validate');
				        				},
										success : function(json) {
											eval("json="+json);
											$.messager.alert(json.title,json.msg,json.level);
											d.dialog('destroy');
											$("#sso_config_${action_id}_datagrid").datagrid('reload');
										}
									});
								}},
								{iconCls : 'icon-undo',
								text:'${action.getProperty('net.esj.background.message','bg.datagrid.reset')}',
								handler:function(){
									$('#sso_config_${action_id}_form').form('clear');
								}}],
					onClose : function() {
						$(this).dialog('destroy');
					}
				});
			}
		}]
	});

});

function sso_config_${action_id}_edit(id){

	$('<div>').dialog({
		href : '${request.contextPath}${namespace?default('')}/mp/sso/config-edit.htm?action_id=${action_id}',
		width:500,   
		height:500,   
		modal : true,
		title : '${action.getText('bg.datagrid.edit')}',
		buttons : [ {
			text : '${action.getText('bg.datagrid.edit')}',
			iconCls : 'icon-edit',
			handler : function() {
				var d = $(this).closest('.window-body');
				$('#sso_config_${action_id}_form').form('submit', {
					url : '${request.contextPath}${namespace?default('')}/mp/sso/config-update.json',
					onSubmit: function(){
						return $(this).form('validate');
    				},
					success : function(json) {
						eval("json="+json);
						$.messager.alert(json.title,json.msg,json.level);
						d.dialog('destroy');
						$("#sso_config_${action_id}_datagrid").datagrid('reload');
					}
				});
			}
		} ],
		onClose : function() {
			$(this).dialog('destroy');
		},
		onLoad : function() {
			$.get('${request.contextPath}${namespace?default('')}/mp/sso/config-load.json?id='+id+'&n='+Math.random(),{},function(json){
				$('#sso_config_${action_id}_form').form('load', json);
			},'json');
		}
	});
	
}



</script>